package com.j48.entrancegurad.mapper;

import com.j48.entrancegurad.model.Character;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;

/**
 * character表操作
 */
@Repository
@Mapper
public interface CharacterMapper {
    /**
     * 查询所有角色
     * @return 角色列表
     */
    @Select("select * from `character` where character_id>1")
    public ArrayList<Character> selectAll();
    /**
     * 按编号查询角色
     * @param character 查询条件
     * @return 查询结果
     */
    @Select("select * from `character` where character_id=#{character_id}")
    public Character selectById(Character character);
    /**
     * 按名称查询角色
     * @param character 查询条件
     * @return 查询结果
     */
    @Select("select * from `character` where character_name=#{character_name} and character_id>1")
    public ArrayList<Character> selectByName(Character character);

    /**
     * 按名称查询角色
     * @param character 查询条件
     * @return 查询结果
     */
    @Select("select * from `character` where character_name=#{character_name}")
    public ArrayList<Character> selectByName1(Character character);

    /**
     * 添加角色
     * @param character 被添加的角色
     * @return 影响数据库数据条数
     */
    @Insert("insert into `character`(character_name) values (#{character_name})")
    public int insert(Character character);

    /**
     * 更新角色信息
     * @param character 更新后的角色
     * @return 影响数据库数据条数
     */
    @Update("update `character` set character_name=#{character_name} where character_id=#{character_id}")
    public int updaterolename(Character character);

    /**
     * 删除角色
     * @param character 被删除角色
     * @return 影响数据库数据条数
     */
    @Delete("delete from `character` where character_name=#{character_name}")
    public int delete(Character character);
}
